package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

public interface OrderMapper extends BaseMapper<Order> {
    @Select("select count(1) from t_order where MEMBER_ID=#{mid} and ORDERDATE=#{orderdate} and SETMEAL_ID=#{sid}")
    int isGenerateOrderOrNot(@Param("mid") Integer mid, @Param("sid") int sid, @Param("orderdate") String orderdate);

    @Select("SELECT tm.NAME as member , ts.name as setmeal, tor.ORDERDATE as orderDate,tor.ORDERTYPE as orderType " +
            "FROM t_order tor,t_member tm,t_setmeal ts " +
            "WHERE tor.SETMEAL_ID = ts.id and tor.MEMBER_ID = tm.ID " +
            "and tor.id = #{oid}")
    Map findOrderInfoByOrderId(@Param("oid") int oid);
}
